import java.util.Scanner;

/** 
   A program reads two integer values
   and prints out the larger of the two.
   If the values are equal, only one of the value is printed.
*/
public class LexiOrder
{
   public static void main(String[] args)
   {
      // Print prompt to enter two words (strings)
      System.out.println("Please enter two words: ");

      // Read in both integer values
      Scanner in = new Scanner(System.in);
      String word1 = in.next();
      String word2 = in.next();

      // Determine the correct alphabetical order of words
      // and print out the words in one line, in order.

      // Your work here
      int length1=word1.length();
      int length2=word2.length();
      int length3,i;
      if(length1>length2)
         length3=length2;
      else 
         length3=length1;
      for(i=0;i<length3;i++)
      {
         if(word1.charAt(i)>word2.charAt(i))
         {
            System.out.println(word2+" "+word1);
            break;
         }
         else if(word1.charAt(i)<word2.charAt(i))
         {
            System.out.println(word1+" "+word2);
            break;
         }
      }
      if(i==length3)
         System.out.println(word1);
   }
}
